#pragma once

#include<iostream>
#include<string>
#include<fstream>

namespace ns_util
{
    class FileUtil
    {
        public:
            static bool ReadFile(const std::string &file_path,std::string *out)
            {
                std::ifstream in(file_path,std::ios::in);
                if(!in.is_open())
                {
                    std::cerr<<"open file"<<file_path<<"error"<<std::endl;
                    return false;

                }
                std::string line;
                //如何理解getline读取到文件结束？他的返回值是一个&，while(bool)本质因为重载了强制性类型转化
                while(std::getline(in,line))
                {
                    *out+=line;
                }
                in.close();
                return true;
            }
    };
}


